//商品图片信息
'use strict';
import React,{Component} from 'react';
import styles from '../style/styles';
import Util from '../common/util';
import {
    View,
    Text,
    ScrollView,
    TouchableOpacity,
    Image
} from 'react-native';
export default class goodsImgInfo extends Component {
    // 构造
    constructor(props) {
        super(props);
        // 初始状态
        this.state = {
            datas:this.props.datas
        };
        this.show = this.show.bind(this)
    }

    componentWillReceiveProps(nextProps) {
        LOG('datas====='+JSON.stringify(nextProps.datas))
        let datas = nextProps.datas;
        this.setState({
            datas:datas
        })
    }


    show() {
        let datas = this.state.datas;
        LOG("datas===="+JSON.stringify(datas))
        let goods = datas.goods
        let wap_description = goods.wap_description;
        LOG('wap_description===='+JSON.stringify(wap_description))
        let that = this;
        let width = Util.size.width;
        let HTML = `
<!DOCTYPE html>
<html>
  <head>
    <title>Hello Static World</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <style type="text/css">
      body {
        margin: 0;
        padding: 0;
        font: 62.5% arial, sans-serif;
        background: #fff;
      }
      img{
         display:block;
         width:` + width + `px;
         height:auto;
      }
    </style>
  </head>
  <body>
  <div>
     ` + wap_description + `
     </div>
  </body>
</html>
`;
        let height;
        let isIos = Util.isIos();
        if (isIos) {
            height = Util.size.height - 110;
        } else {
            height = Util.size.height - 115;
        }
        return (
            <View style={{height:height}}>

            </View>
        )
    }
    show2(){
        let that = this;
        let datas = that.state.datas;
        let goods = datas.goods;
        let goods_detail = goods.goods_detail;
        let rows;
        let list=[];
        for(let item of goods_detail){
            LOG('item===='+item)
            rows=(
               <Image
                    source={{uri:item}}
                    style={styles.goods_detail_img}
                    resizeMode={'contain'}
                    key={item}
               />
            )
            list.push(rows)
        }
        return list;
    }


    render() {

        return (
            <ScrollView style={{flex: 1}}>
                {this.show()}
            </ScrollView>
        )
    }
}